package com.weds.edjk.util;

import com.weds.edjk.vo.ReportMqttVo;
import groovy.util.logging.Slf4j;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

/**
 * @Author zcz
 * @Description http请求工具类
 * @Date 2020-06-12
 */
@Slf4j
public class RestTemplateUtils {

    /**
     * 上送
     * @param url
     * @param mqttVo
     */
    public static ResponseEntity sendMqtt(String url,ReportMqttVo mqttVo){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<ReportMqttVo> request = new HttpEntity<>(mqttVo, headers);
        ResponseEntity<String> response = restTemplate.postForEntity( url, request , String.class );
        return response;
    }
}
